--------------------------------------------------------
--  File created - Tuesday-January-19-2010   
--------------------------------------------------------
--------------------------------------------------------
--  DDL for Sequence ARTISTS_SEQ
--------------------------------------------------------
SET DEFINE OFF

   CREATE SEQUENCE  "ARTISTS_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1947459 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Sequence GENRES_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "GENRES_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 163471 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Sequence USERS_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "USERS_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 191 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Table ARTISTS
--------------------------------------------------------

  CREATE TABLE "ARTISTS" 
   (	"ARTIST_ID" NUMBER, 
	"NAME" VARCHAR2(400)
   ) ;
--------------------------------------------------------
--  DDL for Table CONTINENTS
--------------------------------------------------------

  CREATE TABLE "CONTINENTS" 
   (	"CON_ID" NUMBER, 
	"CON_NAME" VARCHAR2(20)
   ) ;
--------------------------------------------------------
--  DDL for Table DISCS
--------------------------------------------------------

  CREATE TABLE "DISCS" 
   (	"CD_ID" NUMBER, 
	"ARTISTS_ID" NUMBER, 
	"YEAR" NUMBER, 
	"GENRE_ID" NUMBER, 
	"TITLE" VARCHAR2(300), 
	"REVISION" NUMBER
   ) ;
--------------------------------------------------------
--  DDL for Table GENRES
--------------------------------------------------------

  CREATE TABLE "GENRES" 
   (	"GENRE_ID" NUMBER, 
	"GENRE_NAME" VARCHAR2(150), 
	"PARENT_GENRE_ID" NUMBER
   ) ;
--------------------------------------------------------
--  DDL for Table LIKES
--------------------------------------------------------

  CREATE TABLE "LIKES" 
   (	"USER_ID" NUMBER, 
	"TRACK_ID" NUMBER, 
	"CD_ID" NUMBER
   ) ;
--------------------------------------------------------
--  DDL for Table PARENT_GENRES
--------------------------------------------------------

  CREATE TABLE "PARENT_GENRES" 
   (	"GENRE_ID" NUMBER, 
	"GENRE_NAME" VARCHAR2(20)
   ) ;
--------------------------------------------------------
--  DDL for Table SONGS
--------------------------------------------------------

  CREATE TABLE "SONGS" 
   (	"TRACK_ID" NUMBER, 
	"SONG_NAME" VARCHAR2(300), 
	"CD_ID" NUMBER
   ) ;
--------------------------------------------------------
--  DDL for Table USERS
--------------------------------------------------------

  CREATE TABLE "USERS" 
   (	"USER_ID" NUMBER, 
	"USERNAME" VARCHAR2(200), 
	"PASSWORD" VARCHAR2(200), 
	"GENRE_ID" NUMBER, 
	"AGE" NUMBER, 
	"CONTINENT_ID" NUMBER, 
	"SEX" NUMBER
   ) ;

---------------------------------------------------
--   DATA FOR TABLE ARTISTS
--   FILTER = none used
---------------------------------------------------
REM INSERTING into ARTISTS
Insert into ARTISTS (ARTIST_ID,NAME) values (1947439,'dummy');

---------------------------------------------------
--   END DATA FOR TABLE ARTISTS
---------------------------------------------------


---------------------------------------------------
--   DATA FOR TABLE CONTINENTS
--   FILTER = none used
---------------------------------------------------
REM INSERTING into CONTINENTS
Insert into CONTINENTS (CON_ID,CON_NAME) values (1,'Europe');
Insert into CONTINENTS (CON_ID,CON_NAME) values (2,'Asia');
Insert into CONTINENTS (CON_ID,CON_NAME) values (3,'America');
Insert into CONTINENTS (CON_ID,CON_NAME) values (4,'Africa');
Insert into CONTINENTS (CON_ID,CON_NAME) values (5,'Australia');

---------------------------------------------------
--   END DATA FOR TABLE CONTINENTS
---------------------------------------------------


---------------------------------------------------
--   DATA FOR TABLE DISCS
--   FILTER = none used
---------------------------------------------------
REM INSERTING into DISCS
Insert into DISCS (CD_ID,ARTISTS_ID,YEAR,GENRE_ID,TITLE,REVISION) values (0,1947439,0,96203,'dummy',0);

---------------------------------------------------
--   END DATA FOR TABLE DISCS
---------------------------------------------------


---------------------------------------------------
--   DATA FOR TABLE GENRES
--   FILTER = none used
---------------------------------------------------
REM INSERTING into GENRES
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96203,'classical',2);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96204,'country',3);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96205,'data',4);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96206,'folk',5);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96207,'jazz',6);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96208,'misc',7);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96209,'newage',8);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96210,'reggae',9);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96211,'rock',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96212,'soundtrack',11);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98573,'pop',12);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98574,'electro',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98575,'trance',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98576,'electronic',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98577,'house',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98578,'dance',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98579,'alternative',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108668,'hip hop',14);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98581,'metal',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98582,'hard rock',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98583,'unknown',7);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98584,'other',7);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (98585,'rock & roll',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108669,'hiphop',14);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108670,'rap',14);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108671,'gangsta',14);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108672,'west side',14);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108673,'east side',14);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108674,'christian',15);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108675,'gospel',15);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108676,'reggaeton',16);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108677,'salsa',16);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108678,'caribbean',16);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108679,'rumba',16);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108680,'disco',17);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108681,'environmental',8);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108682,'ambient',8);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108683,'world',8);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108684,'meditation',8);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108686,'grunge',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108687,'progressive rock',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108688,'chorus',15);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108689,'chillout',8);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108690,'ballroom',16);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108691,'funk',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108692,'swing',6);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108694,'drum&base',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108695,'r&b',1);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108696,'jungle',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108697,'heavy metal',10);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108698,'dub',13);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108699,'oldies',18);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108700,'instrumental',2);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108701,'chamber',2);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108702,'twist',17);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (108704,'latin',16);
Insert into GENRES (GENRE_ID,GENRE_NAME,PARENT_GENRE_ID) values (96202,'blues',1);

---------------------------------------------------
--   END DATA FOR TABLE GENRES
---------------------------------------------------


---------------------------------------------------
--   DATA FOR TABLE LIKES
--   FILTER = none used
---------------------------------------------------
REM INSERTING into LIKES

---------------------------------------------------
--   END DATA FOR TABLE LIKES
---------------------------------------------------


---------------------------------------------------
--   DATA FOR TABLE PARENT_GENRES
--   FILTER = none used
---------------------------------------------------
REM INSERTING into PARENT_GENRES
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (1,'blues');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (2,'classical');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (3,'country');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (4,'data');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (5,'folk');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (6,'jazz');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (7,'misc');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (8,'newage');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (9,'reggae');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (10,'rock');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (11,'soundtrack');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (12,'pop');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (13,'electro');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (16,'latin');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (14,'rap');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (15,'christian');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (17,'disco');
Insert into PARENT_GENRES (GENRE_ID,GENRE_NAME) values (18,'oldies');

---------------------------------------------------
--   END DATA FOR TABLE PARENT_GENRES
---------------------------------------------------


---------------------------------------------------
--   DATA FOR TABLE SONGS
--   FILTER = none used
---------------------------------------------------
REM INSERTING into SONGS

---------------------------------------------------
--   END DATA FOR TABLE SONGS
---------------------------------------------------


---------------------------------------------------
--   DATA FOR TABLE USERS
--   FILTER = none used
---------------------------------------------------
REM INSERTING into USERS

---------------------------------------------------
--   END DATA FOR TABLE USERS
---------------------------------------------------

--------------------------------------------------------
--  Constraints for Table PARENT_GENRES
--------------------------------------------------------

  ALTER TABLE "PARENT_GENRES" ADD CONSTRAINT "PARENT_GENRES_PK" PRIMARY KEY ("GENRE_ID") ENABLE;
 
  ALTER TABLE "PARENT_GENRES" ADD CONSTRAINT "PARENT_GENRES_UK1" UNIQUE ("GENRE_NAME") ENABLE;
 
  ALTER TABLE "PARENT_GENRES" MODIFY ("GENRE_ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table USERS
--------------------------------------------------------

  ALTER TABLE "USERS" MODIFY ("USER_ID" NOT NULL ENABLE);
 
  ALTER TABLE "USERS" ADD CONSTRAINT "USERS_PK" PRIMARY KEY ("USER_ID") ENABLE;
 
  ALTER TABLE "USERS" ADD CONSTRAINT "USERS_USERNAME_UNIQUE" UNIQUE ("USERNAME") ENABLE;
--------------------------------------------------------
--  Constraints for Table GENRES
--------------------------------------------------------

  ALTER TABLE "GENRES" ADD CONSTRAINT "GENRES_PK" PRIMARY KEY ("GENRE_ID") ENABLE;
 
  ALTER TABLE "GENRES" ADD CONSTRAINT "GENRES_UK1" UNIQUE ("GENRE_NAME") ENABLE;
 
  ALTER TABLE "GENRES" MODIFY ("GENRE_ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table SONGS
--------------------------------------------------------

  ALTER TABLE "SONGS" ADD CONSTRAINT "SONGS_PK" PRIMARY KEY ("TRACK_ID", "CD_ID") ENABLE;
 
  ALTER TABLE "SONGS" MODIFY ("TRACK_ID" NOT NULL ENABLE);
 
  ALTER TABLE "SONGS" MODIFY ("CD_ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table DISCS
--------------------------------------------------------

  ALTER TABLE "DISCS" ADD CONSTRAINT "DISCS_PK" PRIMARY KEY ("CD_ID") ENABLE;
 
  ALTER TABLE "DISCS" MODIFY ("CD_ID" NOT NULL ENABLE);
 
  ALTER TABLE "DISCS" MODIFY ("REVISION" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table CONTINENTS
--------------------------------------------------------

  ALTER TABLE "CONTINENTS" ADD CONSTRAINT "CONTINENTS_PK" PRIMARY KEY ("CON_ID") ENABLE;
 
  ALTER TABLE "CONTINENTS" MODIFY ("CON_ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table LIKES
--------------------------------------------------------

  ALTER TABLE "LIKES" ADD CONSTRAINT "LIKES_PK" PRIMARY KEY ("USER_ID", "TRACK_ID", "CD_ID") ENABLE;
 
  ALTER TABLE "LIKES" MODIFY ("USER_ID" NOT NULL ENABLE);
 
  ALTER TABLE "LIKES" MODIFY ("TRACK_ID" NOT NULL ENABLE);
 
  ALTER TABLE "LIKES" MODIFY ("CD_ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table ARTISTS
--------------------------------------------------------

  ALTER TABLE "ARTISTS" ADD CONSTRAINT "ARTISTS_PK" PRIMARY KEY ("ARTIST_ID") ENABLE;
 
  ALTER TABLE "ARTISTS" MODIFY ("ARTIST_ID" NOT NULL ENABLE);
--------------------------------------------------------
--  DDL for Index ARTISTS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "ARTISTS_PK" ON "ARTISTS" ("ARTIST_ID") 
  ;
--------------------------------------------------------
--  DDL for Index PARENT_GENRES_UK1
--------------------------------------------------------

  CREATE UNIQUE INDEX "PARENT_GENRES_UK1" ON "PARENT_GENRES" ("GENRE_NAME") 
  ;
--------------------------------------------------------
--  DDL for Index USERS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "USERS_PK" ON "USERS" ("USER_ID") 
  ;
--------------------------------------------------------
--  DDL for Index SONGS_SONGNAME
--------------------------------------------------------

  CREATE INDEX "SONGS_SONGNAME" ON "SONGS" ("SONG_NAME") 
  ;
--------------------------------------------------------
--  DDL for Index ARTISTS_ARTISTNAME
--------------------------------------------------------

  CREATE UNIQUE INDEX "ARTISTS_ARTISTNAME" ON "ARTISTS" ("NAME") 
  ;
--------------------------------------------------------
--  DDL for Index GENRES_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "GENRES_PK" ON "GENRES" ("GENRE_ID") 
  ;
--------------------------------------------------------
--  DDL for Index GENRES_UK1
--------------------------------------------------------

  CREATE UNIQUE INDEX "GENRES_UK1" ON "GENRES" ("GENRE_NAME") 
  ;
--------------------------------------------------------
--  DDL for Index SONGS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "SONGS_PK" ON "SONGS" ("TRACK_ID", "CD_ID") 
  ;
--------------------------------------------------------
--  DDL for Index CONTINENTS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "CONTINENTS_PK" ON "CONTINENTS" ("CON_ID") 
  ;
--------------------------------------------------------
--  DDL for Index PARENT_GENRES_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "PARENT_GENRES_PK" ON "PARENT_GENRES" ("GENRE_ID") 
  ;
--------------------------------------------------------
--  DDL for Index LIKES_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "LIKES_PK" ON "LIKES" ("USER_ID", "TRACK_ID", "CD_ID") 
  ;
--------------------------------------------------------
--  DDL for Index USERS_USERNAME_UNIQUE
--------------------------------------------------------

  CREATE UNIQUE INDEX "USERS_USERNAME_UNIQUE" ON "USERS" ("USERNAME") 
  ;
--------------------------------------------------------
--  DDL for Index DISCS_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "DISCS_PK" ON "DISCS" ("CD_ID") 
  ;
--------------------------------------------------------
--  DDL for Index DISCS_DISCNAME
--------------------------------------------------------

  CREATE INDEX "DISCS_DISCNAME" ON "DISCS" ("TITLE") 
  ;


--------------------------------------------------------
--  Ref Constraints for Table DISCS
--------------------------------------------------------

  ALTER TABLE "DISCS" ADD CONSTRAINT "DISCS_ARTISTS_FK1" FOREIGN KEY ("ARTISTS_ID")
	  REFERENCES "ARTISTS" ("ARTIST_ID") ENABLE;
 
  ALTER TABLE "DISCS" ADD CONSTRAINT "DISCS_GENRES_FK1" FOREIGN KEY ("GENRE_ID")
	  REFERENCES "GENRES" ("GENRE_ID") ENABLE;
--------------------------------------------------------
--  Ref Constraints for Table GENRES
--------------------------------------------------------

  ALTER TABLE "GENRES" ADD CONSTRAINT "GENRES_PARENT_GENRES_FK1" FOREIGN KEY ("PARENT_GENRE_ID")
	  REFERENCES "PARENT_GENRES" ("GENRE_ID") ENABLE;


--------------------------------------------------------
--  Ref Constraints for Table SONGS
--------------------------------------------------------

  ALTER TABLE "SONGS" ADD CONSTRAINT "SONGS_DISCS_FK1" FOREIGN KEY ("CD_ID")
	  REFERENCES "DISCS" ("CD_ID") ENABLE;
 
  ALTER TABLE "SONGS" ADD CONSTRAINT "SONGS_SONGS_FK1" FOREIGN KEY ("TRACK_ID", "CD_ID")
	  REFERENCES "SONGS" ("TRACK_ID", "CD_ID") ENABLE;
--------------------------------------------------------
--  Ref Constraints for Table USERS
--------------------------------------------------------

  ALTER TABLE "USERS" ADD CONSTRAINT "USERS_CONTINENTS_FK1" FOREIGN KEY ("CONTINENT_ID")
	  REFERENCES "CONTINENTS" ("CON_ID") ENABLE;
 
  ALTER TABLE "USERS" ADD CONSTRAINT "USERS_PARENT_GENRES_FK1" FOREIGN KEY ("GENRE_ID")
	  REFERENCES "PARENT_GENRES" ("GENRE_ID") ENABLE;
--------------------------------------------------------
--  DDL for Trigger ARTISTS_TRIGGER
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "ARTISTS_TRIGGER" 
BEFORE INSERT ON ARTISTS
FOR EACH ROW
BEGIN
SELECT ARTISTS_SEQ.NEXTVAL INTO :NEW.ARTIST_ID  FROM DUAL;
END;
/
ALTER TRIGGER "ARTISTS_TRIGGER" ENABLE;
--------------------------------------------------------
--  DDL for Trigger GENRES_TRIGGER
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "GENRES_TRIGGER" 
BEFORE INSERT ON GENRES
FOR EACH ROW
BEGIN
SELECT GENRES_SEQ.NEXTVAL INTO :NEW.GENRE_ID  FROM DUAL;
END;
/
ALTER TRIGGER "GENRES_TRIGGER" ENABLE;
--------------------------------------------------------
--  DDL for Trigger USERS_TRIGGER
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "USERS_TRIGGER" 
BEFORE INSERT ON USERS
FOR EACH ROW
BEGIN
SELECT USERS_SEQ.NEXTVAL INTO :NEW.USER_ID  FROM DUAL;
END;
/
ALTER TRIGGER "USERS_TRIGGER" ENABLE;
--------------------------------------------------------
--  DDL for View SONGSDATA
--------------------------------------------------------

  CREATE OR REPLACE FORCE VIEW "SONGSDATA" ("SONG_NAME", "TITLE", "NAME", "GENRE_NAME", "PARENT_GENRE_ID", "YEAR", "TRACK_ID", "CD_ID") AS 
  SELECT songs.song_name,
    discs.title,
    artists.name,
    genres.genre_name,
    genres.parent_genre_id,
    discs.year,
    songs.track_id,
    discs.cd_id
  FROM songs
  JOIN discs
  ON songs.cd_id=discs.cd_id
  JOIN artists
  ON artists.artist_id=discs.artists_id
  JOIN genres
  ON discs.genre_id=genres.genre_id;
  
  SET DEFINE ON
